from django.contrib import admin
from .models import Consumable, Weapon, Armor
from import_export.admin import ImportExportModelAdmin


class ConsumableAdmin(ImportExportModelAdmin, admin.ModelAdmin):
    list_display = ('name', 'illustrate', 'level', 'icon')
    # 用于在创建用户时使用
    add_fieldsets = ('name', 'icon', 'illustrate', 'level', 'is_tradable', 'weight')
    list_display_links = ('name', )
    search_fields = ['name', 'illustrate', 'level', 'is_tradable', 'weight']


class WeaponAdmin(ImportExportModelAdmin, admin.ModelAdmin):
    list_display = ('name', 'illustrate', 'level', 'type', 'icon')
    # 用于在创建用户时使用
    add_fieldsets = ('name', 'type', 'icon', 'illustrate', 'level', 'is_tradable', 'enhancement', 'weight', 'quality',
                     'min_attack', 'max_attack', 'agility', 'slot', 'durability')
    list_display_links = ('name', )
    search_fields = ['name', 'type', 'illustrate', 'level', 'is_tradable', 'enhancement', 'weight', 'quality',
                     'min_attack', 'max_attack', 'agility', 'slot', 'durability']


class ArmorAdmin(ImportExportModelAdmin, admin.ModelAdmin):
    list_display = ('name', 'illustrate', 'level', 'type', 'icon')
    # 用于在创建用户时使用
    add_fieldsets = ('name', 'type', 'icon', 'illustrate', 'level', 'is_tradable', 'enhancement', 'weight', 'quality',
                     'min_attack', 'max_attack', 'agility', 'slot', 'lucky', 'durability')
    list_display_links = ('name', )
    search_fields = ['name', 'type', 'illustrate', 'level', 'is_tradable', 'enhancement', 'weight', 'quality',
                     'defense', 'agility', 'slot', 'lucky', 'durability']


admin.site.register(Consumable, ConsumableAdmin)
admin.site.register(Weapon, WeaponAdmin)
admin.site.register(Armor, ArmorAdmin)
